﻿using Model;
using System.Data;

namespace BLL
{
    public class QS_PROJECT_CODEBLL : BaseBLL
    {
        public DataTable Select(string whr)
        {
            string sql = @"select * from QS_PROJECT_CODE where 1=1 ";
            if (!string.IsNullOrEmpty(whr))
            {
                sql += whr;
            }
            DataTable dt = base.Query(sql, null, null, null, null);
            return dt;
        }

        public int Insert(QS_PROJECT_CODE model)
        {
            model.N_CODEID = (int)GetSequence("SEQ_N_PROID");
            var sql = @"INSERT INTO QS_PROJECT_CODE (N_CODEID,N_PROID,C_CODE) VALUES ({0},{1},'{2}')";
            sql = string.Format(sql, model.N_CODEID, model.N_PROID, model.C_CODE);
            return NoQuery(sql);
        }

        public int Update(QS_PROJECT_CODE model)
        {
            var sql = @"UPDATE QS_PROJECT_CODE SET N_PROID = {1},C_CODE = '{2}' WHERE N_CODEID = {0}";
            sql = string.Format(sql, model.N_CODEID, model.N_PROID, model.C_CODE);
            return NoQuery(sql);
        }

        public int Delete(string codeId)
        {
            var sql = @"DELETE FROM QS_PROJECT_CODE WHERE N_CODEID in ({0})";

            sql = string.Format(sql, codeId);
            return NoQuery(sql);
        }
    }
}